import {
    Server
} from "../api/http"
const login = (msg) => {
    let data = Server.post('/login', msg)
    return data
}
const menus = () => {
    let data = Server.get('/menus')
    return data
}
const users = (params) => {
    let data = Server.get('/users', {
        params
    })
    return data
}
const adduse = (mes) => {
    let data = Server.post('/users',
        mes
    )
    return data
}
const Delete = (id) => {
    let data = Server.delete('/users/' + id

    )
    return data
}
const switc = (msg) => {
    let data = Server.put(msg)
    return data
}
const bian = (msg) => {
    let data = Server.put("users/" + msg.id,
        msg)
    return data
}
const role = () => {
    let data = Server.get("roles")
    return data
}
const roles = (mes) => {
    let data = Server.put(`users/${mes.id}/role`, {
        rid: mes.rid
    })
    return data
}
const addrol = (mes) => {
    let data = Server.post("roles",
        mes
    )
    return data
}
const deleterole = (mes) => {
    let data = Server.delete("roles/" + mes)
    return data
}
const putrole = (mes) => {
    let data = Server.put("roles/" + mes.roleId, mes)
    return data
}
const tree = () => {
    let data = Server.get("rights/tree")
    return data
}
const right = (id, mes) => {
    let data = Server.post(`roles/${id}/rights`, {
        rids: mes
    })
    return data
}
const rights = (id, mes) => {
    let data = Server.delete(`roles/${id}/rights/${mes}`)
    return data
}

//权限列表
const sights = () => {
        let data = Server.get("rights/list")
        return data
    }
    //数据列表
const getReports = () => {
        let data = Server.get("reports/type/1")
        return data
    }
    //订单
const orders = () => {
    let data = Server.get("orders?query=&pagenum=1&pagesize=5")
    return data
}
const goods = (num, size) => {
    let data = Server.get(`goods?query=&pagenum=${num}&pagesize=${size}`)
    return data
}
const categories = () => {
    let data = Server.get("categories")
    return data
}
const attributes = (id, a) => {
    let data = Server.get(`categories/${id}/attributes?sel=${a}`)
    return data
}
const upload = () => {
    let data = Server.post("upload")
    return data
}
const goodsss = (mes) => {
    let data = Server.post("goods", mes)
    return data
}
const deletegoods = (id) => {
    let data = Server.delete("goods/" + id)
    return data
}

//商品分类
const getCategories = (a, b) => {
    let data = Server.get(`categories?type=3&pagenum=${a}&pagesize=${b}`)
    return data
}



//添加分类
const updataCategories = (msg) => {
    let data = Server.post("categories", msg)
    return data
}


//商品分类级联菜单
const setCategories = () => {
    let data = Server.get("categories")
    return data
}


//删除商品分类
const delCategories = (id) => {
    let data = Server.delete('/categories/' + id)
    return data
}

//编辑商品分类
const putCategories = (id, name) => {
        let data = Server.put('/categories/' + id, name)
        return data
    }
    //添加动态参数
const addA = (id, mes) => {
        let data = Server.post(`categories/${id}/attributes`, mes)
        return data
    }
    //修改
const attrId = (id, mes, idd) => {
    let data = Server.put(`categories/${id}/attributes/${mes}`, idd)
    return data
}
const deless = (id, mes) => {
    let data = Server.delete(`categories/${id}/attributes/${mes}`)
    return data
}
const tagg = (cateId, attr_id, attr_name, attr_sel, attr_vals) => {
    // console.log();
    let data = Server.put(`categories/${cateId}/attributes/${attr_id}`, {
        attr_name,
        attr_sel,
        attr_vals
    })
    return data
}
export {
    putCategories,
    delCategories,
    setCategories,
    updataCategories,
    getCategories,
    login,
    menus,
    users,
    adduse,
    Delete,
    switc,
    bian,
    role,
    roles,
    addrol,
    deleterole,
    putrole,
    tree,
    right,
    rights,
    sights,
    getReports,
    orders,
    goods,
    categories,
    attributes,
    upload,
    goodsss,
    deletegoods,
    addA,
    attrId,
    deless,
    tagg
}